<?php
$langList = $this->params['langList'];
$langDefault = $this->params['langDefault'];
	
$datas = $this->datas;
echo !empty($datas['id']) ? '<h2>Edit Help</h2>' : '<h2>New Help</h2>';
$id	= !empty($datas['id']) ? $datas['id'] : '';
$dirImg			= $this->dirImg;
?>
 
<div class="tabBox">
      <form action="<?php echo $this->url(array('module' => 'admin' , 'controller' => 'help' , 'action' => 'add','id'=>$id),'default',true);?>" method="post" class="frmTabs" <?php echo empty($id)? 'id="frmListNewHelp"':'id="frmListEditHelp"'?> ENCTYPE="multipart/form-data">
	  <input type="hidden" name="type" value="<?php echo !empty($datas['type']) ? $datas['type'] : 'image' ;?>" />
        <?php
        		$msgErrs = $this->msgErrs;
        		if(is_array($msgErrs) && count($msgErrs) > 0){
        			foreach($msgErrs as $err){
        			?>
        			<p><span><strong><?php echo $err;?></strong></span></p>
        		<?php 	
        			}
        		} 
        	?>
        <div class="content">
		<?php
           	if(is_array($langList) && count($langList)>0){      	?>
           		
        	<ul class="tab">
        	
        	<?php foreach ( $langList as $key => $value ) {
       			if($key == $langDefault){
       				echo '<li class="tabHandler active" id="lang_'.$key.'">'.$value.'</li>';
       			} else {
       				echo '<li class="tabHandler" id="lang_'.$key.'">'.$value.'</li>';
       			}
			}
		?>
		</ul>
		<?php } ?>
				<table class="tabContent" id="tabContent_<?php echo $langDefault; ?>">
				<tr>
					<td align="left">
						<label for="title">Title :<font color="red"><strong>*</strong></font></label>
					</td>
					<td align="left">
						<input type="text" size="50" id="name" name="title" value="<?php echo !empty($datas['title']) ? $datas['title'] : '' ;?>"/>
					</td>
				</tr>
				<tr>
					<td align="left">
						<label for="description" class="description">Description :</label>
					</td>
					<td align="left">
						<textarea rows="10" cols="100" id="description" name="description"><?php echo !empty($datas['description']) ? $datas['description'] : '' ;?></textarea>
					</td>
				</tr>
				<tr>
					<td align="left">
						<label for="text" class="text">Text :</label>
					</td>
					<td align="left">
						<textarea rows="10" cols="100" id="content" name="content[]"><?php echo !empty($datas['content']) ? $datas['content'] : '' ;?></textarea>
					</td>
				</tr>
				<?php 
				if($datas['type']=='image'):
				?>
				<tr>
					<td align="left">
						<label for="image" class="image">Image :</label>
					</td>
					<td align="left"><input type="file" name="file[]" id="file" size="30"
				value="<?php echo !empty($datas['file']) ? $datas['file']: '';?>"> <br />
				<?php
				if(!empty($datas['file'])){
					$fileName 		= $datas['file'];
					$urlImg 	= $this->url(array('module' => 'admin' , 'controller' => 'help' , 'action' => 'getimage' , 'path' => base64_encode($dirImg) , 'filename' => base64_encode($fileName)), 'default', true);
					?> &nbsp; <img alt="" src="<?php echo $urlImg;?>"
				width="200px;" height="150px;"> <input type="checkbox"
				name="delImg" id="delImg"> You want to delete this image? <?php }?>
				</td>
				<td>
					
				</td>
				</tr>
				<tr>
    				<td colspan="2" align="right" style="text-align: right;">
    					<a href="#" id="addmore" > Add more</a>
    				</td>
    				
				</tr>					
				<?php else: ?>
				<tr>
					<td align="left">
						<label for="video" class="video">Link video :</label>
					</td>
					<td align="left">
						<input type="text" id="file" name="file[]" value="<?php echo !empty($datas['file']) ? $datas['file'] : '' ;?>" />
						<br />
						<label> Ex: http://player.vimeo.com/video/32351411?title=0&byline=0&portrait=0&color=d6d6d6</label>
					</td>
				</tr>
				<tr>
    				<td colspan="2" align="right" style="text-align: right;">
    					<a href="#" id="addmore" > Add more</a>
    				</td>
    				
				</tr>
				<?php endif;?>
				<tr>
					<td align="left">
						<label for="order" class="order">Order :</label>
					</td>
					<td align="left">
						<input type="text" id="order" name="order" value="<?php echo !empty($datas['order']) ? $datas['order'] : '' ;?>" size="2" />
					</td>
				</tr>
					
					<tr>
					<td align="left">
					<?php
							$checked = 'checked="checked"';
							if(!empty($datas['id'])){
								$checked = ($datas['status'] == 1) ? 'checked="checked"': '';
							} 
						?>
						<label for="published">Published :</label>
					</td>
					<td align="left">
						<input type="checkbox" id="status" name="status" checked="checked"/>
					</td>
				</tr>
			  </table>
		   <?php
		  if(is_array($langList) && count($langList)>0){      	
		  	foreach ( $langList as $k => $v ) {
		  		if($k != $langDefault){
					?>
					<table class="tabContent hidden" id="tabContent_<?php echo $k; ?>">
					<tr>
						<td align="left">
							<label for="title">Title :</label>
						</td>
						<td align="left">
							<input size="50" type="text" id="name<?php echo $k; ?>" name="title_<?php echo $k; ?>" value="<?php echo !empty($datas["title_$k"]) ? $datas["title_$k"] : '' ;?>"/>
						</td>
					</tr>
					<tr>
						<td align="left">
							<label for="description" class="description">Description :</label>
						</td>
						<td align="left">
							<textarea rows="10" cols="100" id="description<?php echo $k; ?>" name="description_<?php echo $k; ?>"><?php echo !empty($datas["description_$k"]) ? $datas["description_$k"] : '' ;?></textarea>
						</td>
					</tr>
					<tr>
						<td align="left">
							<label for="text" class="text">Text :</label>
						</td>
						<td align="left">
							<textarea rows="10" cols="100" id="content<?php echo $k; ?>" name="content_<?php echo $k; ?>[]"><?php echo !empty($datas["content_$k"]) ? $datas["content_$k"] : '' ;?></textarea>
						</td>
					</tr>
				  </table>
					<?php
				}
			}
		}			
		  ?>
         <p>
	          <a  class="blueBtn" href="<?php echo $this->url(array('module' => 'admin' , 'controller' => 'help' , 'action' => 'index'),'default',true);?>" >Cancel</a>
	           <input type="submit" class="greenBtn" title="Save" value ="Save"/> 
        </p>
        </div>
      </form>
</div>